package org.buptsse.thread;

import java.io.IOException;
import java.util.ArrayList;

import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.message.BasicNameValuePair;
import org.buptsse.utils.APPConstant;
import org.buptsse.utils.ConnectionChecker;
import org.buptsse.utils.HttpHelper;

import android.content.Context;
import android.os.Handler;
import android.os.Message;

public class DeleteSellThread extends Thread {

	private Context context;
	private Handler handler;
	private String sellid;
	
	public DeleteSellThread(Context context,Handler handler,String sellid)
	{
		this.context=context;
		this.handler=handler;
		this.sellid=sellid;
	}
	
	public void run()
	{
		if(ConnectionChecker.CheckConnection(context, handler)==false)
			return;
		ArrayList<NameValuePair> param=new ArrayList<NameValuePair>();
		param.add(new BasicNameValuePair("sellid", sellid));
		try {
			String result=HttpHelper.sendPost(APPConstant.deleteSellUrl, param);
			if(result.contains("success"))
			{
				Message msg=handler.obtainMessage(APPConstant.deleteSellFinish);
				handler.sendMessage(msg);
			}else {
				Message msg=handler.obtainMessage(APPConstant.deleteSellError);
				handler.sendMessage(msg);
			}
		} catch (ClientProtocolException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
